package com.feri.fitness.cs.controller;

import com.feri.fitness.common.config.SystemConfig;
import com.feri.fitness.common.dto.MoodAddDto;
import com.feri.fitness.common.dto.MoodRefwordDto;
import com.feri.fitness.cs.exception.MoodException;
import com.feri.fitness.cs.service.intf.MoodService;
import com.feri.fitness.common.vo.R;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.*;

/**
 * 千锋郑州Java学科欢迎你
 * @program: Fitness
 * @description: 控制层实现常用的外部接口
 * @author: Feri
 * @create: 2023-01-12 08:59:28
 */
@RestController
@RequestMapping("/server/mood/")
public class MoodController{
    /**
    *注入业务逻辑层对象*/
    @Resource
    private MoodService service;

    @PostMapping("add.do")
    public R add(@RequestBody MoodAddDto dto, HttpServletRequest request){
        return service.save(dto,request.getIntHeader(SystemConfig.HEADER_UID));
    }
    @PostMapping("forward.do")
    public R forward(@RequestBody MoodRefwordDto dto,HttpServletRequest request){
        return service.refword(dto,request.getIntHeader(SystemConfig.HEADER_UID));
    }
    @GetMapping("hot.do")
    public R hot(){
        return service.queryHot();
    }
    @GetMapping("follow.do")
    public R follow(HttpServletRequest request){
        return service.queryFollow(request.getIntHeader(SystemConfig.HEADER_UID));
    }
    @GetMapping("city.do")
    public R city(@RequestParam String city){
        return service.queryCity(city);
    }

    @GetMapping("del.do")
    public R del(@RequestParam int mid) throws MoodException {
        return service.del(mid);
    }
}